//
//  FXWeakerTimerTarget.m
//  NSTimer 引用问题 --解除timer 对控制器的引用问题
//
//  Created by 袁飞霞 on 16/5/12.
//  Copyright © 2016年 cn.sophietobeabetterone. All rights reserved.
//

#import "FXWeakerTimerTarget.h"
@interface FXWeakerTimerTarget()
@property (nonatomic, weak) id aTarget;
@property (nonatomic, assign) SEL selector;
@end

@implementation FXWeakerTimerTarget
+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)ti target:(id)aTarget selector:(SEL)aSelector userInfo:(nullable id)userInfo repeats:(BOOL)yesOrNo
{
    FXWeakerTimerTarget *target = [[FXWeakerTimerTarget alloc]init];
    target.aTarget = aTarget;
    target.selector = aSelector;
    
    return [NSTimer scheduledTimerWithTimeInterval:ti target: target selector:@selector(update) userInfo:userInfo repeats:yesOrNo];
    
}
-(void)update
{
    [self.aTarget performSelector:self.selector withObject:nil afterDelay:0
     ];
    

}
@end
